﻿/// <reference path="../Scripts/_references.js" />
$(document).ready(function () {

    $('.btnprocessos')
      .button({
          icons: {
              primary: "ui-icon-check"
          }
      })
      .click(function (event) {
          event.preventDefault();
          var link_name = $(this).attr('name');
          $.ajax({
              url: '/Admin/Process',
              type: 'POST',
              data: {
                  type: link_name
              },
              success: function () {
                  alert('sucess');
              },
              error: function () {
                  alert("error");
              }
          });
      });

    $('#Date').datetimepicker({ dateFormat: 'dd/mm/yy' });

    var JornadaId = $('#JornadaId');
    var option_select = '<option value=""><< Seleccione a jornada >></option>';
    JornadaId.append(option_select);

    $('#CompeticaoId').change(function () {
        var competicao_id = $(this).val();
        $.getJSON('/Admin/GetJornadas', { idcompeticao: competicao_id }, function (data) {
            $('#JornadaId option').remove();
            JornadaId.append(option_select);
            $.each(data, function (i, item) {
                var option = '<option value="' + item.Id + '">' + item.Name + '</option>';
                JornadaId.append(option);
            });
        });
    });
});